/**
 * Copyright (C), 2018-2018, 河北东软有限公司
 * FileName: StudentController
 * Author:   Administrator
 * Date:     2018/4/24 13:59
 * Description:
 * History:
 * <author>          <time>          <version>          <desc>
 * 作者姓名           修改时间           版本号              描述
 */
package pers.fqq.dlfd.student.controller;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import pers.fqq.dlfd.student.entity.OrgEntity;
import pers.fqq.dlfd.student.resposity.OrgRepo;
import pers.fqq.dlfd.student.service.StudentService;

import java.io.File;
import java.util.List;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author Administrator
 * @create 2018/4/24
 * @since 1.0.0
 */
@EnableAutoConfiguration
@RestController
public class StudentController {

    @Autowired
    StudentService studentService;

    @Autowired
    OrgRepo orgRepo;

    @RequestMapping(value = "/student", method = RequestMethod.GET)
    @ApiOperation(value = "查找学生", notes = "根据id和name查找学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "用户id", required = true, paramType = "query", dataType = "string"),
            @ApiImplicitParam(name = "name", value = "用户名", required = false, paramType = "query", dataType = "string")
    })
    public void findStudent(@RequestParam String id, @RequestParam(required = false, defaultValue = "guagua") String name) {
        ImportParams params = new ImportParams();
        params.setTitleRows(1);     //导入数据的时候排除标题行
        params.setHeadRows(1);      //导入数据的时候排除表头行
        List<OrgEntity> list = ExcelImportUtil.importExcel(
                new File("emp2.xls"),
                OrgEntity.class, params);
        orgRepo.saveAll(list);
//        StudentEntity studentEntity = studentService.findStudent(id, name);
//        if (studentEntity != null) {
//            return studentEntity.getId() + studentEntity.getName() + studentEntity.getPassword();
//        } else {
//            return "查无此人";
//        }
    }


}